/**
 * HomeCtrl.java
 *
 */
package com.navidove.web.manager.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.navidove.appspotlight.model.bo.SysUser;
import com.navidove.appspotlight.model.service.SysParamService;
import com.navidove.appspotlight.model.service.SysUserService;

/**
 * HomeCtrl
 *
 * @author $Author$
 * @version $Revision$
 * @date $Date$
 * @url $URL$
 */
@Controller
public class HomeCtrl {
	
	@Autowired
	private SysUserService sysUserService;
	
	@Autowired
	private SysParamService sysParamService;

	@RequestMapping(value="/login")
	public String login() {
		return "login";
	}
	 
	@RequestMapping(value="/home/home")
	public String home(Model model) {
		SysUser sysUser = sysUserService.getCurrentSysUser();
		model.addAttribute("sysUser", sysUser);
		return "home/home";
	}
	
	@ResponseBody
	@RequestMapping(value="/sysParam/edit")
	public String setparam(Model model,
			@RequestParam("name") String name,
			@RequestParam("value") String value) {
		
		sysParamService.saveSysParam(name, value);
		
		return "Success";
	}
}
